package datapack

import (
	"broker/interface/imodel"
	"broker/struct/model"
	"encoding/binary"
)

/**
 * @Description
 * @Author huan.wang
 * @Date 2021/4/27 12:24 上午
 **/

type SubscribeAckDataPack struct {
}

func NewSubscribeAckDataPack() *SubscribeAckDataPack {
	return &SubscribeAckDataPack{}
}

func (s SubscribeAckDataPack) Pack(message imodel.IMessage) ([]byte, error) {
	subAckMsg := message.(*model.SubscribeAckMessage)
	subAckData := make([]byte, 2)
	binary.BigEndian.PutUint16(subAckData, subAckMsg.PacketID)
	subAckData = append(subAckData, subAckMsg.ReturnCode)
	return subAckData, nil

}

func (s SubscribeAckDataPack) UnPack(bytes []byte) (imodel.IMessage, error) {
	panic("implement me")
}
